package remote.physics
{
	import flash.geom.Point;
	import flash.geom.Vector3D;
	
	/**
	 * 匀加速运动 
	 *
	 * @author 银魂飞雪
	 * @date 2011-9-16
	 */
	public class UniformlyAccelerated
	{
		private var _v0:Vector3D;
		private var _a:Vector3D;
		private var _t0:Number;
		private var _position0:Point;
		
		/**
		 * 实例化 
		 * @param v0 初速度
		 * @param a 加速度
		 * @param t0 起始时间
		 * @param position0 起始位置
		 * 
		 */		
		public function UniformlyAccelerated(v0:Vector3D, a:Vector3D, t0:Number, position0:Point)
		{
			_v0 = v0;
			_a = a;
			_t0 = t0;
			_position0 = position0;
		}
		
		/**
		 * 根据时间计算对应的速度 
		 * @param time
		 * @return 
		 * 
		 */		
		public function getV1(time:Number):Vector3D
		{
			var gapTime:Number = time - t0;
			return new Vector3D(v0.x + a.x * gapTime, v0.y + a.y * gapTime, v0.z + a.z * gapTime);
		}
		
		/**
		 * 根据时间计算对应的位置
		 * @return 
		 * 
		 */		
		public function getPosition1(time:Number):Point
		{
			var gapTime:Number = time - t0;
			var x:Number = position0.x + v0.x * gapTime + a.x * Math.pow(gapTime, 2) / 2;
			var y:Number = position0.y + v0.y * gapTime + a.y * Math.pow(gapTime, 2) / 2;
			return new Point(x, y);
		}

		/**
		 * 初速度 
		 * @return 
		 * 
		 */		
		public function get v0():Vector3D
		{
			return _v0;
		}

		public function set v0(value:Vector3D):void
		{
			_v0 = value;
		}

		/**
		 * 加速度 
		 * @return 
		 * 
		 */		
		public function get a():Vector3D
		{
			return _a;
		}

		public function set a(value:Vector3D):void
		{
			_a = value;
		}

		/**
		 * 起始时间 
		 * @return 
		 * 
		 */		
		public function get t0():Number
		{
			return _t0;
		}

		public function set t0(value:Number):void
		{
			_t0 = value;
		}

		/**
		 * 起始位置 
		 * @return 
		 * 
		 */		
		public function get position0():Point
		{
			return _position0;
		}

		public function set position0(value:Point):void
		{
			_position0 = value;
		}


	}
}